import { SpecialRewardItemInfo } from "./info/SpecialRewardItemInfo";
import { DateParser } from "../../common/tools/DateParser";
import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
type int = number;
//class SpecialRewardItemConfig
    
    export  class SpecialRewardItemConfig
    {
        constructor()
        {
            
            this._map = new Map<any, any> /* flash.utils.Dictionary */();
            if (SpecialRewardItemConfig._instance != null) 
            {
                throw new Error(" SpecialRewardItemConfig 单例 ");
            }
            this.init();
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=arg1;
            for(loc2 of loc4) 
            {
                loc1 = new SpecialRewardItemInfo();
                loc1.code = loc2.code;
                loc1.limit = loc2.limit;
                loc1.effectDay = DateParser.strToDateNormal(loc2.effectDay);
                loc1.jsStr = loc2.jsStr;
                loc1.parse();
                this._map[loc1.code] = loc1;
            }
            return;
        }

        public init(): void
        {
            var loc1=ConfigManager.instance.getJSONByFileName("t_special_reward_item.json");
            this.write(loc1);
            return;
        }

        public getInfoByCode(arg1: int): SpecialRewardItemInfo
        {
            return this._map[arg1] as SpecialRewardItemInfo;
        }

        public isLimitByType(arg1: int, arg2: int): Boolean
        {
            var loc1=this._map[arg1] as SpecialRewardItemInfo;
            if (loc1 && loc1.limit & arg2) 
            {
                return true;
            }
            return false;
        }

        public static get instance(): SpecialRewardItemConfig
        {
            if (SpecialRewardItemConfig._instance == null) 
            {
                SpecialRewardItemConfig._instance = new SpecialRewardItemConfig();
            }
            return SpecialRewardItemConfig._instance;
        }

        /* internal */ /* var */_map: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ static /* var */_instance: SpecialRewardItemConfig;
    }
